import { storage } from '@/utils/storage'
/*
 * @Author: CQJ
 * @Date: 2022-08-25 20:00:27
 * @LastEditors: CQJ
 * @LastEditTime: 2022-09-08 16:55:22
 * @Description:
 */
import { reactive } from 'vue'
type Key = string
interface AlbumState {
  // 所属分类
  album_id?: string | undefined
  album_status: number | undefined
  // 子分类关键词
  album_keyword: string | undefined
  site_id?: string
}

// 状态管理
export const albumState = reactive<AlbumState>({
  album_status: undefined,
  album_id: undefined,
  album_keyword: undefined,
  site_id: ''
})
interface IStatusState {
  isEdit: boolean
  addAlbumVisible: boolean
  addSubClassify: boolean
  selectedRowKeys: Key[]
  isAdd: boolean
}
export const statusState = reactive<IStatusState>({
  isEdit: false,
  addAlbumVisible: false,
  addSubClassify: false,
  selectedRowKeys: [],
  isAdd: false
})
interface ILeftData {
  categ_id: string | undefined
  subcateg_id: string | undefined
  picture_id: string | undefined
  picture_keyword: string | undefined
  site_id: string | undefined
  status: number | undefined
}
export const leftState = reactive<ILeftData>({
  categ_id: undefined,
  subcateg_id: undefined,
  picture_id: undefined,
  picture_keyword: undefined,
  site_id: undefined,
  status: 1
})
export const resetState = () => {
  for (const i in albumState) {
    switch (i) {
      case 'album_id':
        albumState[i] = undefined
        break
      case 'album_keyword':
        albumState[i] = undefined
        break
      case 'album_status':
        albumState[i] = undefined
        break
    }
  }
}
export const resetDialogState = () => {
  let key: keyof ILeftData
  for (key in leftState) {
    leftState[key] = undefined
  }
}
